package me.yannchou.weicoer.ui.main.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import me.yannchou.weicoer.R;

/**
 * @author zhouyanbin
 * @time 2014/11/25.21:30
 */
public class MainActivity extends ActionBarActivity {

    private Toolbar toolbar;
    private MainFragment mainFragment;
    private DrawerLayout drawerLayout;
    private ActionBarDrawerToggle drawerToggle;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        toolbar = (Toolbar) findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);
        toolbar.getWrapper().setHomeButtonEnabled(true);
        toolbar.setTitleTextColor(Color.WHITE);
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
        drawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.main_back,R.string.main_title);
        drawerToggle.syncState();
        drawerLayout.setDrawerListener(drawerToggle);
        mainFragment = (MainFragment) Fragment.instantiate(this,MainFragment.class.getName());
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.main_fragment_layout,mainFragment)
                .commit();


    }
}
